<template>
	<view>

		<cu-custom bgColor="bg-gradual-red" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">关于活动</block>
		</cu-custom>

		<scroll-view scroll-x class="bg-white nav">
			<view class="flex text-center">
				<view class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in navList" :key="index"
				 @tap="tabSelect" :data-id="index">
					{{item}}
				</view>
			</view>
		</scroll-view>

		<h-card :a-act="aAct"></h-card>
	</view>
</template>

<script>
	const {
		request
	} = require('@/utils/t-request.js');
	import HCard from '@/components/home/h-card.vue';
	export default {
		data() {
			return {
				navList: ['参加活动', '发起活动'],
				TabCur: 0,
				join: [],
				create: []
			}
		},
		computed: {
			aAct() {
				return this.TabCur > 0 ? this.create : this.join;
			}
		},
		components: {
			'h-card': HCard
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
			}
		},
		onLoad(options) {
			this.TabCur = options.id;
		},
		onShow() {
			request({
				url: "/users/act-list",
				method: 'POST',
			}).then(res => {
				this.join = res.join;
				this.create = res.create;
			})
		}
	}
</script>

<style>

</style>
